#!/bin/bash
cd ~/app-root/data/temp/xpi/swf/
curl -s https://bitbucket.org/kafan15536900/haoutil/commits/branch/master |grep -o '\/kafan15536900\/.*\?at=master' | sed '2,$d'>commits.txt
if ! diff -q commits.txt commits2.txt; then
mv -f commits2.txt commits.txt
curl -s https://bitbucket.org/$(cat commits.txt) |grep -o "\/kafan15536900\/.*\.swf?at=master" |sort -u |sed -e 's#src#raw#' -e 's#?at=master##' -e 's#^#https:\/\/bitbucket\.org&#' >list.txt
wget --no-check-certificate -N -i list.txt
rm -f list.txt
mv -f player4player2.swf pptv.swf
ls ~/app-root/data/temp/xpi/swf/ |grep -o ".*\.swf" >~/app-root/repo/swf/swf.txt
mv -f *.swf ~/app-root/data/swf/
List=$(ls ~/app-root/repo/swf/*.swf|grep -o "[a-zA-Z0-9_\.\-]*\.swf")
if [ "$List" ]; then
    echo '<!DOCTYPE HTML> <html><head><meta name="viewport" content="width=device-width, initial-scale=1"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><H2>当前位于 /</H2>'>~/app-root/repo/swf/index.html
    for i in $List; do
        echo "<A HREF=\"$i\">$i</A><br>">>~/app-root/repo/swf/index.html
        n=$(($n+1))
    done
    echo "<H3>共$n个文件</H3></body></html>">>~/app-root/repo/swf/index.html
fi
fi
curl -s http://noads.mujj.us:9882/swf/rulelist/redirectlist | base64 -d |sed -e 's#\",#\",\n#g' -e 's#}, {#\n},{\n\t#g' -e 's#\[{#\[{\n\t#' -e 's#}\]#\n}\]#' >url.txt
